package com.eight.homepage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.TbArticle;
import com.eight.common.pojo.TbBottomArticle;
import com.eight.common.vo.Result;
import com.eight.homepage.service.BottomArticleService;
import com.eight.homepage.vo.BottomArticleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/5/30 10:42
 */
@RestController
@RequestMapping("/home/bottomarticle")
@Api(tags = "底部文章")
public class BottomArticleController {

    @Autowired
    private BottomArticleService bottomArticleService;

    @ApiOperation("分页查询底部文章")
    @PostMapping("/getAllBottomArticle/{currentPage}/{pageSize}")
    public Result getAllBottomArticle(@PathVariable Integer currentPage,
                                      @PathVariable Integer pageSize,
                                      @RequestBody BottomArticleVo bottomArticleVo){
        Page<TbBottomArticle> page = bottomArticleService.findPage(currentPage, pageSize, bottomArticleVo);
        return  Result.success(page);
    }

    @ApiOperation(("修改状态"))
    @PostMapping("/changeStatus/{id}/{isDisable}")
    public Result changeStatus(@PathVariable String id , @PathVariable Integer isDisable){
       int i =  bottomArticleService.updateStatus(id,isDisable);
       return Result.success();
    }

    @ApiOperation("删除底部文章")
    @PostMapping("/delete")
    public Result delete(@RequestBody TbBottomArticle id){
      int i =  bottomArticleService.delete(id);
      return Result.success();
    }

    @ApiOperation("添加底部文章")
    @PostMapping("/addBottomArticle")
    public Result add(@RequestBody TbBottomArticle tbBottomArticle){
       int i =  bottomArticleService.insert(tbBottomArticle);
       return Result.success();
    }
    @ApiOperation("修改底部文章")
    @PostMapping("/editBottomArticle")
    public Result edit(@RequestBody TbBottomArticle tbBottomArticle){
        int i =  bottomArticleService.update(tbBottomArticle);
        return Result.success();
    }


}
